//
// Created by user on 2022/2/24.
//
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
vector<vector<string>> groupAnagrams(vector<string>& strs) {
    unordered_map<string, vector<string>> map;
    for (string& str : strs) {
        string key = str;
        sort(key.begin(), key.end());
        map[key].emplace_back(str);
    }
    vector<vector<string>> ans;
    for(auto it=map.begin(); it!=map.end();it++){
        ans.emplace_back(it->second);
    }
    return ans;
}